<?php

class Application_Form_DocumentoMov extends Zend_Form
{
    public function init()
    {
        $this->addElementPrefixPath('My_Filter', 'My/Filter', 'FILTER');
        $this->addElementPrefixPath('My_Validate', 'My/Validate', 'VALIDATE');
        $validacaoData = new Zend_Validate_Date('dd/MM/yyyy');
        $validacaoData->setMessages(array( // error messages
            Zend_Validate_Date::INVALID_DATE => 'A data \'%value%\' não é válida.',
            Zend_Validate_Date::FALSEFORMAT => 'O formato de data \'%value%\' não é válido.'
        ));

        $this->clearDecorators();
        $decorators = array(
            array('ViewHelper'),
            array('Errors'),
            array('Label',array(
                'class' => 'leftalign'
            )),
            array('HtmlTag',array('tag' => 'li'))
        );

        $this->setElementFilters(array(
                'StripTags',
                'StringTrim'
        ))->setName('documento_mov');
 
        $id             = new Zend_Form_Element_Hidden('id');
        $id->setDecorators(array('ViewHelper'));
        
        $documento_id   = new Zend_Form_Element_Hidden('documento_id');
        $documento_id->setDecorators(array('ViewHelper'));
        
        $responsavel_id = new Zend_Form_Element_Hidden('responsavel_id');
        $responsavel_id->setDecorators(array('ViewHelper'));

        $destino = new Zend_Form_Element_Text('destino');
        $destino->setLabel('Destino')
            ->addValidator('NotEmpty')
            ->setAttrib('Class', 'span5')
            ->setDecorators($decorators);

        $data_decorators = array(
            'UiWidgetElement',
            array('Errors'),
            array('Label',array(
                'class' => 'leftalign'
            )),
            array('HtmlTag',array('tag' => 'li'))
            );

        $dt_criacao = new ZendX_JQuery_Form_Element_DatePicker(
                    'dt_criacao',array('jQueryParams' => array(
                        'dateFormat' => 'dd/mm/yy',
                        'defaultDate' => date('',time()) )));
        $dt_criacao->setLabel('Data movimentação')
            ->setRequired ()
            ->setDecorators($data_decorators);

        $historico = new Zend_Form_Element_Textarea('historico');
        $historico->setLabel('historico')
            ->addValidator('NotEmpty')
            ->setAttrib('Class', 'span5')
            ->setAttrib('Rows','3')
            ->setDecorators($decorators);

        // Botão 'Enviar'
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Salvar');
        $submit->setDecorators(array(
            array('ViewHelper'),
            array('HtmlTag',
                array(
                'tag' => 'li',
                'class' => 'submit'))
        ));

        $this->setDecorators(array(
           'FormElements',
            array('HtmlTag',array('tag'=>'ul')),
            array(
                array(
                    'DivTag'=>'HtmlTag'
                ),
                array(
                    'tag'=>'div',
                    'class'=>'FormDiv'
                )
            ),
            'Form'
        ));
        
        $this->addElements(array(
            $id, 
            $documento_id,
            $responsavel_id,
            $destino, 
            $historico, 
            $dt_criacao, 
            $submit));
        
    }

}